package Stream;

import Generricity1.Teacher;
import Stream.Teacher3;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class StreamDemo3 {
    public static void main(String[] args) {
        List<Teacher3>teacher=new ArrayList<>();
        teacher.add(new Teacher3("Alice",25,5000));
        teacher.add(new Teacher3("Bob",30,6000));
        teacher.add(new Teacher3("Charlie",28,5500));

        teacher.stream().sorted((t1,t2)->t1.getAge()-t2.getAge()).forEach(System.out::println);
        Optional<Teacher3> optionalTeacher=teacher.stream().max((t1,t2)->Double.compare(t1.getSalary(),t2.getSalary()));

        // 修正类型不匹配，使用Teacher3接收结果
        Teacher3 maxT = optionalTeacher.get();
        System.out.println("工资最高的老师: " + maxT);
    }
}
